{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入 swindex 模块\n",
    "from opendatatools import swindex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index_code</th>\n",
       "      <th>index_name</th>\n",
       "      <th>section_name</th>\n",
       "      <th>start_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>803611</td>\n",
       "      <td>申万价值优势</td>\n",
       "      <td>量化策略</td>\n",
       "      <td>2004/12/31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>803612</td>\n",
       "      <td>申万价值发现</td>\n",
       "      <td>量化策略</td>\n",
       "      <td>2004/12/31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>803613</td>\n",
       "      <td>申万价值稳健</td>\n",
       "      <td>量化策略</td>\n",
       "      <td>2004/12/31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>801001</td>\n",
       "      <td>申万50</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>801002</td>\n",
       "      <td>申万中小板</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>801003</td>\n",
       "      <td>申万Ａ指</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>801005</td>\n",
       "      <td>申万创业板</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>2009/11/5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>801300</td>\n",
       "      <td>申万300指数</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>801901</td>\n",
       "      <td>基金重仓</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>801903</td>\n",
       "      <td>基金核心</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>801905</td>\n",
       "      <td>申万重点</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>801250</td>\n",
       "      <td>申万制造</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>801260</td>\n",
       "      <td>申万消费</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>801270</td>\n",
       "      <td>申万投资</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>801280</td>\n",
       "      <td>申万服务</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>802611</td>\n",
       "      <td>申万传媒</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>2004/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>802613</td>\n",
       "      <td>养老指数</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>2016/10/31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>802612</td>\n",
       "      <td>申万电子</td>\n",
       "      <td>市场表征</td>\n",
       "      <td>2004/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>801010</td>\n",
       "      <td>农林牧渔</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>801020</td>\n",
       "      <td>采掘</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   index_code index_name section_name  start_date\n",
       "0      803611     申万价值优势         量化策略  2004/12/31\n",
       "1      803612     申万价值发现         量化策略  2004/12/31\n",
       "2      803613     申万价值稳健         量化策略  2004/12/31\n",
       "3      801001       申万50         市场表征  1999/12/30\n",
       "4      801002      申万中小板         市场表征  1999/12/30\n",
       "5      801003       申万Ａ指         市场表征  1999/12/30\n",
       "6      801005      申万创业板         市场表征   2009/11/5\n",
       "7      801300    申万300指数         市场表征  1999/12/30\n",
       "8      801901       基金重仓         市场表征  1999/12/30\n",
       "9      801903       基金核心         市场表征  1999/12/30\n",
       "10     801905       申万重点         市场表征  1999/12/30\n",
       "11     801250       申万制造         市场表征  1999/12/30\n",
       "12     801260       申万消费         市场表征  1999/12/30\n",
       "13     801270       申万投资         市场表征  1999/12/30\n",
       "14     801280       申万服务         市场表征  1999/12/30\n",
       "15     802611       申万传媒         市场表征  2004/12/30\n",
       "16     802613       养老指数         市场表征  2016/10/31\n",
       "17     802612       申万电子         市场表征  2004/12/30\n",
       "18     801010       农林牧渔         一级行业  1999/12/30\n",
       "19     801020         采掘         一级行业  1999/12/30"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取申万指数列表\n",
    "df, msg = swindex.get_index_list()\n",
    "df.head(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         量化策略\n",
       "3         市场表征\n",
       "18        一级行业\n",
       "52        风格指数\n",
       "70        定制发布\n",
       "71    申万商品期货指数\n",
       "79         新三板\n",
       "Name: section_name, dtype: object"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['section_name'].drop_duplicates()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index_code</th>\n",
       "      <th>index_name</th>\n",
       "      <th>section_name</th>\n",
       "      <th>start_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>801010</td>\n",
       "      <td>农林牧渔</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>801020</td>\n",
       "      <td>采掘</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>801030</td>\n",
       "      <td>化工</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>801050</td>\n",
       "      <td>有色金属</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>801060</td>\n",
       "      <td>建筑建材</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>801070</td>\n",
       "      <td>机械设备</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>801080</td>\n",
       "      <td>电子元器件</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>801090</td>\n",
       "      <td>交运设备</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>801100</td>\n",
       "      <td>信息设备</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>801110</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>801120</td>\n",
       "      <td>食品饮料</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>801130</td>\n",
       "      <td>纺织服装</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>801140</td>\n",
       "      <td>轻工制造</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>801150</td>\n",
       "      <td>医药生物</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>801160</td>\n",
       "      <td>公用事业</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>801170</td>\n",
       "      <td>交通运输</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>801180</td>\n",
       "      <td>房地产</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>801190</td>\n",
       "      <td>金融服务</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>801200</td>\n",
       "      <td>商业贸易</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>801210</td>\n",
       "      <td>餐饮旅游</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>801220</td>\n",
       "      <td>信息服务</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>801230</td>\n",
       "      <td>综合</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>801710</td>\n",
       "      <td>建筑材料</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>801720</td>\n",
       "      <td>建筑装饰</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>801730</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>801740</td>\n",
       "      <td>国防军工</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>801750</td>\n",
       "      <td>计算机</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>801760</td>\n",
       "      <td>传媒</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>801770</td>\n",
       "      <td>通信</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>801780</td>\n",
       "      <td>银行</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>801790</td>\n",
       "      <td>非银金融</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>801880</td>\n",
       "      <td>汽车</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>801890</td>\n",
       "      <td>机械设备</td>\n",
       "      <td>一级行业</td>\n",
       "      <td>1999/12/30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   index_code index_name section_name  start_date\n",
       "18     801010       农林牧渔         一级行业  1999/12/30\n",
       "19     801020         采掘         一级行业  1999/12/30\n",
       "20     801030         化工         一级行业  1999/12/30\n",
       "21     801040         钢铁         一级行业  1999/12/30\n",
       "22     801050       有色金属         一级行业  1999/12/30\n",
       "23     801060       建筑建材         一级行业  1999/12/30\n",
       "24     801070       机械设备         一级行业  1999/12/30\n",
       "25     801080      电子元器件         一级行业  1999/12/30\n",
       "26     801090       交运设备         一级行业  1999/12/30\n",
       "27     801100       信息设备         一级行业  1999/12/30\n",
       "28     801110       家用电器         一级行业  1999/12/30\n",
       "29     801120       食品饮料         一级行业  1999/12/30\n",
       "30     801130       纺织服装         一级行业  1999/12/30\n",
       "31     801140       轻工制造         一级行业  1999/12/30\n",
       "32     801150       医药生物         一级行业  1999/12/30\n",
       "33     801160       公用事业         一级行业  1999/12/30\n",
       "34     801170       交通运输         一级行业  1999/12/30\n",
       "35     801180        房地产         一级行业  1999/12/30\n",
       "36     801190       金融服务         一级行业  1999/12/30\n",
       "37     801200       商业贸易         一级行业  1999/12/30\n",
       "38     801210       餐饮旅游         一级行业  1999/12/30\n",
       "39     801220       信息服务         一级行业  1999/12/30\n",
       "40     801230         综合         一级行业  1999/12/30\n",
       "41     801710       建筑材料         一级行业  1999/12/30\n",
       "42     801720       建筑装饰         一级行业  1999/12/30\n",
       "43     801730       电气设备         一级行业  1999/12/30\n",
       "44     801740       国防军工         一级行业  1999/12/30\n",
       "45     801750        计算机         一级行业  1999/12/30\n",
       "46     801760         传媒         一级行业  1999/12/30\n",
       "47     801770         通信         一级行业  1999/12/30\n",
       "48     801780         银行         一级行业  1999/12/30\n",
       "49     801790       非银金融         一级行业  1999/12/30\n",
       "50     801880         汽车         一级行业  1999/12/30\n",
       "51     801890       机械设备         一级行业  1999/12/30"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.section_name == '一级行业']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index_code</th>\n",
       "      <th>index_name</th>\n",
       "      <th>start_date</th>\n",
       "      <th>weight</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000708</td>\n",
       "      <td>大冶特钢</td>\n",
       "      <td>2015-07-29 00:00:00</td>\n",
       "      <td>0.6239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000709</td>\n",
       "      <td>河钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>4.1277</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000717</td>\n",
       "      <td>韶钢松山</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>3.0578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000761</td>\n",
       "      <td>本钢板材</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>0.6290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000778</td>\n",
       "      <td>新兴铸管</td>\n",
       "      <td>2009-06-01 00:00:00</td>\n",
       "      <td>3.8359</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>000825</td>\n",
       "      <td>太钢不锈</td>\n",
       "      <td>2017-07-03 00:00:00</td>\n",
       "      <td>4.3453</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>000898</td>\n",
       "      <td>鞍钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>2.9310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>000932</td>\n",
       "      <td>华菱钢铁</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>4.2571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>000959</td>\n",
       "      <td>首钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.6933</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>002075</td>\n",
       "      <td>沙钢股份</td>\n",
       "      <td>2017-07-03 00:00:00</td>\n",
       "      <td>6.8167</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>002110</td>\n",
       "      <td>三钢闽光</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>4.0276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>002318</td>\n",
       "      <td>久立特材</td>\n",
       "      <td>2009-11-23 00:00:00</td>\n",
       "      <td>1.0456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>002443</td>\n",
       "      <td>金洲管道</td>\n",
       "      <td>2012-10-08 00:00:00</td>\n",
       "      <td>0.9540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>002478</td>\n",
       "      <td>常宝股份</td>\n",
       "      <td>2012-10-08 00:00:00</td>\n",
       "      <td>0.7751</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>002756</td>\n",
       "      <td>永兴特钢</td>\n",
       "      <td>2015-05-06 00:00:00</td>\n",
       "      <td>0.7681</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>600010</td>\n",
       "      <td>包钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>12.0725</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>600019</td>\n",
       "      <td>宝钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>16.3186</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>600022</td>\n",
       "      <td>山东钢铁</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>3.6232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>600117</td>\n",
       "      <td>西宁特钢</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>0.6278</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>600126</td>\n",
       "      <td>杭钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>0.6578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>600231</td>\n",
       "      <td>凌钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.0912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>600282</td>\n",
       "      <td>南钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>3.4929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>600307</td>\n",
       "      <td>酒钢宏兴</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>2.2497</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>600399</td>\n",
       "      <td>*ST抚钢</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.6024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>600507</td>\n",
       "      <td>方大特钢</td>\n",
       "      <td>2011-10-10 00:00:00</td>\n",
       "      <td>2.1237</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>600569</td>\n",
       "      <td>安阳钢铁</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.6475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>600581</td>\n",
       "      <td>八一钢铁</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.5857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>600782</td>\n",
       "      <td>新钢股份</td>\n",
       "      <td>2009-06-01 00:00:00</td>\n",
       "      <td>2.6431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>600808</td>\n",
       "      <td>马钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>3.5982</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>601003</td>\n",
       "      <td>柳钢股份</td>\n",
       "      <td>2008-06-02 00:00:00</td>\n",
       "      <td>1.5858</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>601005</td>\n",
       "      <td>重庆钢铁</td>\n",
       "      <td>2018-07-16 00:00:00</td>\n",
       "      <td>4.8323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>603878</td>\n",
       "      <td>武进不锈</td>\n",
       "      <td>2016-12-01 21:21:00</td>\n",
       "      <td>0.3581</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   index_code index_name          start_date   weight\n",
       "0      000708       大冶特钢 2015-07-29 00:00:00   0.6239\n",
       "1      000709       河钢股份 2008-06-02 00:00:00   4.1277\n",
       "2      000717       韶钢松山 2008-06-02 00:00:00   3.0578\n",
       "3      000761       本钢板材 2008-06-02 00:00:00   0.6290\n",
       "4      000778       新兴铸管 2009-06-01 00:00:00   3.8359\n",
       "5      000825       太钢不锈 2017-07-03 00:00:00   4.3453\n",
       "6      000898       鞍钢股份 2008-06-02 00:00:00   2.9310\n",
       "7      000932       华菱钢铁 2008-06-02 00:00:00   4.2571\n",
       "8      000959       首钢股份 2008-06-02 00:00:00   1.6933\n",
       "9      002075       沙钢股份 2017-07-03 00:00:00   6.8167\n",
       "10     002110       三钢闽光 2008-06-02 00:00:00   4.0276\n",
       "11     002318       久立特材 2009-11-23 00:00:00   1.0456\n",
       "12     002443       金洲管道 2012-10-08 00:00:00   0.9540\n",
       "13     002478       常宝股份 2012-10-08 00:00:00   0.7751\n",
       "14     002756       永兴特钢 2015-05-06 00:00:00   0.7681\n",
       "15     600010       包钢股份 2008-06-02 00:00:00  12.0725\n",
       "16     600019       宝钢股份 2008-06-02 00:00:00  16.3186\n",
       "17     600022       山东钢铁 2008-06-02 00:00:00   3.6232\n",
       "18     600117       西宁特钢 2008-06-02 00:00:00   0.6278\n",
       "19     600126       杭钢股份 2008-06-02 00:00:00   0.6578\n",
       "20     600231       凌钢股份 2008-06-02 00:00:00   1.0912\n",
       "21     600282       南钢股份 2008-06-02 00:00:00   3.4929\n",
       "22     600307       酒钢宏兴 2008-06-02 00:00:00   2.2497\n",
       "23     600399      *ST抚钢 2008-06-02 00:00:00   1.6024\n",
       "24     600507       方大特钢 2011-10-10 00:00:00   2.1237\n",
       "25     600569       安阳钢铁 2008-06-02 00:00:00   1.6475\n",
       "26     600581       八一钢铁 2008-06-02 00:00:00   1.5857\n",
       "27     600782       新钢股份 2009-06-01 00:00:00   2.6431\n",
       "28     600808       马钢股份 2008-06-02 00:00:00   3.5982\n",
       "29     601003       柳钢股份 2008-06-02 00:00:00   1.5858\n",
       "30     601005       重庆钢铁 2018-07-16 00:00:00   4.8323\n",
       "31     603878       武进不锈 2016-12-01 21:21:00   0.3581"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取申万指数成分信息\n",
    "df, msg = swindex.get_index_cons('801040')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>amount</th>\n",
       "      <th>close</th>\n",
       "      <th>date</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>open</th>\n",
       "      <th>vol</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4480</th>\n",
       "      <td>5810798179</td>\n",
       "      <td>2580.99</td>\n",
       "      <td>2018-07-04</td>\n",
       "      <td>2622.34</td>\n",
       "      <td>2574.47</td>\n",
       "      <td>2574.52</td>\n",
       "      <td>1135277967</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4481</th>\n",
       "      <td>4566360551</td>\n",
       "      <td>2509.97</td>\n",
       "      <td>2018-07-05</td>\n",
       "      <td>2560.12</td>\n",
       "      <td>2507.67</td>\n",
       "      <td>2560.12</td>\n",
       "      <td>968486836</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4482</th>\n",
       "      <td>4419332200</td>\n",
       "      <td>2526.22</td>\n",
       "      <td>2018-07-06</td>\n",
       "      <td>2549.05</td>\n",
       "      <td>2489.34</td>\n",
       "      <td>2504.49</td>\n",
       "      <td>946944251</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4483</th>\n",
       "      <td>4468407439</td>\n",
       "      <td>2586.60</td>\n",
       "      <td>2018-07-09</td>\n",
       "      <td>2587.83</td>\n",
       "      <td>2537.11</td>\n",
       "      <td>2540.41</td>\n",
       "      <td>870432831</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4484</th>\n",
       "      <td>5650783818</td>\n",
       "      <td>2618.04</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2636.72</td>\n",
       "      <td>2580.62</td>\n",
       "      <td>2580.62</td>\n",
       "      <td>1042313172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4485</th>\n",
       "      <td>4709644014</td>\n",
       "      <td>2583.35</td>\n",
       "      <td>2018-07-11</td>\n",
       "      <td>2587.18</td>\n",
       "      <td>2541.89</td>\n",
       "      <td>2566.00</td>\n",
       "      <td>893596171</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4486</th>\n",
       "      <td>5869825987</td>\n",
       "      <td>2630.89</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>2640.93</td>\n",
       "      <td>2597.41</td>\n",
       "      <td>2597.41</td>\n",
       "      <td>1081922523</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4487</th>\n",
       "      <td>5736538215</td>\n",
       "      <td>2642.66</td>\n",
       "      <td>2018-07-13</td>\n",
       "      <td>2661.27</td>\n",
       "      <td>2614.53</td>\n",
       "      <td>2640.10</td>\n",
       "      <td>1014290176</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4488</th>\n",
       "      <td>3918306410</td>\n",
       "      <td>2635.78</td>\n",
       "      <td>2018-07-16</td>\n",
       "      <td>2647.23</td>\n",
       "      <td>2618.89</td>\n",
       "      <td>2639.96</td>\n",
       "      <td>666897555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4489</th>\n",
       "      <td>4003854198</td>\n",
       "      <td>2601.77</td>\n",
       "      <td>2018-07-17</td>\n",
       "      <td>2625.66</td>\n",
       "      <td>2576.88</td>\n",
       "      <td>2623.82</td>\n",
       "      <td>681257203</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4490</th>\n",
       "      <td>3448545707</td>\n",
       "      <td>2592.14</td>\n",
       "      <td>2018-07-18</td>\n",
       "      <td>2622.20</td>\n",
       "      <td>2591.70</td>\n",
       "      <td>2605.32</td>\n",
       "      <td>621140437</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4491</th>\n",
       "      <td>6206422302</td>\n",
       "      <td>2638.94</td>\n",
       "      <td>2018-07-19</td>\n",
       "      <td>2648.83</td>\n",
       "      <td>2609.15</td>\n",
       "      <td>2609.15</td>\n",
       "      <td>1082396855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4492</th>\n",
       "      <td>5931049224</td>\n",
       "      <td>2670.70</td>\n",
       "      <td>2018-07-20</td>\n",
       "      <td>2670.76</td>\n",
       "      <td>2604.46</td>\n",
       "      <td>2631.98</td>\n",
       "      <td>1074295469</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4493</th>\n",
       "      <td>8204466930</td>\n",
       "      <td>2736.37</td>\n",
       "      <td>2018-07-23</td>\n",
       "      <td>2745.88</td>\n",
       "      <td>2645.69</td>\n",
       "      <td>2649.79</td>\n",
       "      <td>1454597629</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4494</th>\n",
       "      <td>13120801390</td>\n",
       "      <td>2811.14</td>\n",
       "      <td>2018-07-24</td>\n",
       "      <td>2869.00</td>\n",
       "      <td>2777.25</td>\n",
       "      <td>2777.25</td>\n",
       "      <td>2240875425</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4495</th>\n",
       "      <td>10705729951</td>\n",
       "      <td>2863.74</td>\n",
       "      <td>2018-07-25</td>\n",
       "      <td>2892.43</td>\n",
       "      <td>2797.25</td>\n",
       "      <td>2810.90</td>\n",
       "      <td>2030123769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4496</th>\n",
       "      <td>7250850920</td>\n",
       "      <td>2835.66</td>\n",
       "      <td>2018-07-26</td>\n",
       "      <td>2863.36</td>\n",
       "      <td>2814.87</td>\n",
       "      <td>2851.14</td>\n",
       "      <td>1357808617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4497</th>\n",
       "      <td>9310444138</td>\n",
       "      <td>2885.78</td>\n",
       "      <td>2018-07-27</td>\n",
       "      <td>2895.02</td>\n",
       "      <td>2832.40</td>\n",
       "      <td>2866.16</td>\n",
       "      <td>1767200012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4498</th>\n",
       "      <td>10083074612</td>\n",
       "      <td>2902.99</td>\n",
       "      <td>2018-07-30</td>\n",
       "      <td>2953.46</td>\n",
       "      <td>2879.37</td>\n",
       "      <td>2887.25</td>\n",
       "      <td>1827252229</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4499</th>\n",
       "      <td>5972629769</td>\n",
       "      <td>2886.14</td>\n",
       "      <td>2018-07-31</td>\n",
       "      <td>2899.53</td>\n",
       "      <td>2844.01</td>\n",
       "      <td>2884.07</td>\n",
       "      <td>1029216898</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           amount    close       date     high      low     open         vol\n",
       "4480   5810798179  2580.99 2018-07-04  2622.34  2574.47  2574.52  1135277967\n",
       "4481   4566360551  2509.97 2018-07-05  2560.12  2507.67  2560.12   968486836\n",
       "4482   4419332200  2526.22 2018-07-06  2549.05  2489.34  2504.49   946944251\n",
       "4483   4468407439  2586.60 2018-07-09  2587.83  2537.11  2540.41   870432831\n",
       "4484   5650783818  2618.04 2018-07-10  2636.72  2580.62  2580.62  1042313172\n",
       "4485   4709644014  2583.35 2018-07-11  2587.18  2541.89  2566.00   893596171\n",
       "4486   5869825987  2630.89 2018-07-12  2640.93  2597.41  2597.41  1081922523\n",
       "4487   5736538215  2642.66 2018-07-13  2661.27  2614.53  2640.10  1014290176\n",
       "4488   3918306410  2635.78 2018-07-16  2647.23  2618.89  2639.96   666897555\n",
       "4489   4003854198  2601.77 2018-07-17  2625.66  2576.88  2623.82   681257203\n",
       "4490   3448545707  2592.14 2018-07-18  2622.20  2591.70  2605.32   621140437\n",
       "4491   6206422302  2638.94 2018-07-19  2648.83  2609.15  2609.15  1082396855\n",
       "4492   5931049224  2670.70 2018-07-20  2670.76  2604.46  2631.98  1074295469\n",
       "4493   8204466930  2736.37 2018-07-23  2745.88  2645.69  2649.79  1454597629\n",
       "4494  13120801390  2811.14 2018-07-24  2869.00  2777.25  2777.25  2240875425\n",
       "4495  10705729951  2863.74 2018-07-25  2892.43  2797.25  2810.90  2030123769\n",
       "4496   7250850920  2835.66 2018-07-26  2863.36  2814.87  2851.14  1357808617\n",
       "4497   9310444138  2885.78 2018-07-27  2895.02  2832.40  2866.16  1767200012\n",
       "4498  10083074612  2902.99 2018-07-30  2953.46  2879.37  2887.25  1827252229\n",
       "4499   5972629769  2886.14 2018-07-31  2899.53  2844.01  2884.07  1029216898"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取申万指数日线\n",
    "df, msg = swindex.get_index_daily('801040')\n",
    "df.tail(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>avg_float_mv</th>\n",
       "      <th>chg_pct</th>\n",
       "      <th>close</th>\n",
       "      <th>date</th>\n",
       "      <th>dividend_yield_ratio</th>\n",
       "      <th>float_mv</th>\n",
       "      <th>index_code</th>\n",
       "      <th>index_name</th>\n",
       "      <th>pb</th>\n",
       "      <th>pe</th>\n",
       "      <th>turn_rate</th>\n",
       "      <th>volume</th>\n",
       "      <th>vwap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>211.95</td>\n",
       "      <td>-0.13</td>\n",
       "      <td>2796.41</td>\n",
       "      <td>2018-08-02</td>\n",
       "      <td>2.50</td>\n",
       "      <td>6,782.51</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.41</td>\n",
       "      <td>10.06</td>\n",
       "      <td>1.0944</td>\n",
       "      <td>15.78</td>\n",
       "      <td>6.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>212.15</td>\n",
       "      <td>-2.98</td>\n",
       "      <td>2800.04</td>\n",
       "      <td>2018-08-01</td>\n",
       "      <td>2.49</td>\n",
       "      <td>6,788.84</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.41</td>\n",
       "      <td>10.07</td>\n",
       "      <td>1.0272</td>\n",
       "      <td>14.81</td>\n",
       "      <td>6.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>219.53</td>\n",
       "      <td>-0.58</td>\n",
       "      <td>2886.14</td>\n",
       "      <td>2018-07-31</td>\n",
       "      <td>2.42</td>\n",
       "      <td>7,025.08</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.45</td>\n",
       "      <td>10.38</td>\n",
       "      <td>0.7139</td>\n",
       "      <td>10.29</td>\n",
       "      <td>7.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>220.82</td>\n",
       "      <td>0.60</td>\n",
       "      <td>2902.99</td>\n",
       "      <td>2018-07-30</td>\n",
       "      <td>2.40</td>\n",
       "      <td>7,066.24</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.46</td>\n",
       "      <td>10.44</td>\n",
       "      <td>1.2674</td>\n",
       "      <td>18.27</td>\n",
       "      <td>7.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>218.77</td>\n",
       "      <td>1.77</td>\n",
       "      <td>2885.78</td>\n",
       "      <td>2018-07-27</td>\n",
       "      <td>2.42</td>\n",
       "      <td>7,000.73</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.45</td>\n",
       "      <td>10.38</td>\n",
       "      <td>1.2257</td>\n",
       "      <td>17.67</td>\n",
       "      <td>7.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>214.61</td>\n",
       "      <td>-0.98</td>\n",
       "      <td>2835.66</td>\n",
       "      <td>2018-07-26</td>\n",
       "      <td>2.46</td>\n",
       "      <td>6,867.56</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.43</td>\n",
       "      <td>10.20</td>\n",
       "      <td>0.9418</td>\n",
       "      <td>13.58</td>\n",
       "      <td>7.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>217.40</td>\n",
       "      <td>1.87</td>\n",
       "      <td>2863.74</td>\n",
       "      <td>2018-07-25</td>\n",
       "      <td>2.44</td>\n",
       "      <td>6,956.89</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.44</td>\n",
       "      <td>10.30</td>\n",
       "      <td>1.4081</td>\n",
       "      <td>20.30</td>\n",
       "      <td>7.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>213.47</td>\n",
       "      <td>2.73</td>\n",
       "      <td>2811.14</td>\n",
       "      <td>2018-07-24</td>\n",
       "      <td>2.48</td>\n",
       "      <td>6,831.03</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.42</td>\n",
       "      <td>10.11</td>\n",
       "      <td>1.5543</td>\n",
       "      <td>22.41</td>\n",
       "      <td>6.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>207.30</td>\n",
       "      <td>2.46</td>\n",
       "      <td>2736.37</td>\n",
       "      <td>2018-07-23</td>\n",
       "      <td>2.55</td>\n",
       "      <td>6,633.54</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.38</td>\n",
       "      <td>9.84</td>\n",
       "      <td>1.0089</td>\n",
       "      <td>14.55</td>\n",
       "      <td>6.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>201.51</td>\n",
       "      <td>1.20</td>\n",
       "      <td>2670.70</td>\n",
       "      <td>2018-07-20</td>\n",
       "      <td>2.61</td>\n",
       "      <td>6,448.37</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.34</td>\n",
       "      <td>9.61</td>\n",
       "      <td>0.7451</td>\n",
       "      <td>10.74</td>\n",
       "      <td>6.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>198.40</td>\n",
       "      <td>1.81</td>\n",
       "      <td>2638.94</td>\n",
       "      <td>2018-07-19</td>\n",
       "      <td>2.65</td>\n",
       "      <td>6,348.79</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.33</td>\n",
       "      <td>9.49</td>\n",
       "      <td>0.7508</td>\n",
       "      <td>10.82</td>\n",
       "      <td>6.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>193.80</td>\n",
       "      <td>-0.37</td>\n",
       "      <td>2592.14</td>\n",
       "      <td>2018-07-18</td>\n",
       "      <td>2.70</td>\n",
       "      <td>6,201.70</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.30</td>\n",
       "      <td>9.32</td>\n",
       "      <td>0.4308</td>\n",
       "      <td>6.21</td>\n",
       "      <td>6.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>194.20</td>\n",
       "      <td>-1.29</td>\n",
       "      <td>2601.77</td>\n",
       "      <td>2018-07-17</td>\n",
       "      <td>2.68</td>\n",
       "      <td>6,214.45</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.31</td>\n",
       "      <td>9.36</td>\n",
       "      <td>0.4725</td>\n",
       "      <td>6.81</td>\n",
       "      <td>6.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>196.78</td>\n",
       "      <td>-0.26</td>\n",
       "      <td>2635.78</td>\n",
       "      <td>2018-07-16</td>\n",
       "      <td>2.65</td>\n",
       "      <td>6,296.81</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.32</td>\n",
       "      <td>9.47</td>\n",
       "      <td>0.4635</td>\n",
       "      <td>6.67</td>\n",
       "      <td>6.56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>79.33</td>\n",
       "      <td>0.45</td>\n",
       "      <td>2642.66</td>\n",
       "      <td>2018-07-13</td>\n",
       "      <td>2.65</td>\n",
       "      <td>2,617.82</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.34</td>\n",
       "      <td>9.53</td>\n",
       "      <td>1.5000</td>\n",
       "      <td>10.14</td>\n",
       "      <td>6.56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>78.97</td>\n",
       "      <td>1.84</td>\n",
       "      <td>2630.89</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>2.67</td>\n",
       "      <td>2,606.16</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.33</td>\n",
       "      <td>9.49</td>\n",
       "      <td>1.6000</td>\n",
       "      <td>10.82</td>\n",
       "      <td>6.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>187.49</td>\n",
       "      <td>-1.32</td>\n",
       "      <td>2583.35</td>\n",
       "      <td>2018-07-11</td>\n",
       "      <td>2.69</td>\n",
       "      <td>6,187.29</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.30</td>\n",
       "      <td>9.32</td>\n",
       "      <td>0.6196</td>\n",
       "      <td>8.94</td>\n",
       "      <td>6.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>190.51</td>\n",
       "      <td>1.22</td>\n",
       "      <td>2618.04</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2.64</td>\n",
       "      <td>6,286.77</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.32</td>\n",
       "      <td>9.44</td>\n",
       "      <td>0.7228</td>\n",
       "      <td>10.42</td>\n",
       "      <td>6.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>187.71</td>\n",
       "      <td>2.39</td>\n",
       "      <td>2586.60</td>\n",
       "      <td>2018-07-09</td>\n",
       "      <td>2.47</td>\n",
       "      <td>6,194.27</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.30</td>\n",
       "      <td>9.33</td>\n",
       "      <td>0.6036</td>\n",
       "      <td>8.70</td>\n",
       "      <td>6.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>182.63</td>\n",
       "      <td>0.65</td>\n",
       "      <td>2526.22</td>\n",
       "      <td>2018-07-06</td>\n",
       "      <td>2.53</td>\n",
       "      <td>6,026.92</td>\n",
       "      <td>801040</td>\n",
       "      <td>钢铁</td>\n",
       "      <td>1.27</td>\n",
       "      <td>9.11</td>\n",
       "      <td>0.6567</td>\n",
       "      <td>9.47</td>\n",
       "      <td>6.21</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   avg_float_mv chg_pct    close       date dividend_yield_ratio  float_mv  \\\n",
       "0        211.95   -0.13  2796.41 2018-08-02                 2.50  6,782.51   \n",
       "1        212.15   -2.98  2800.04 2018-08-01                 2.49  6,788.84   \n",
       "2        219.53   -0.58  2886.14 2018-07-31                 2.42  7,025.08   \n",
       "3        220.82    0.60  2902.99 2018-07-30                 2.40  7,066.24   \n",
       "4        218.77    1.77  2885.78 2018-07-27                 2.42  7,000.73   \n",
       "5        214.61   -0.98  2835.66 2018-07-26                 2.46  6,867.56   \n",
       "6        217.40    1.87  2863.74 2018-07-25                 2.44  6,956.89   \n",
       "7        213.47    2.73  2811.14 2018-07-24                 2.48  6,831.03   \n",
       "8        207.30    2.46  2736.37 2018-07-23                 2.55  6,633.54   \n",
       "9        201.51    1.20  2670.70 2018-07-20                 2.61  6,448.37   \n",
       "10       198.40    1.81  2638.94 2018-07-19                 2.65  6,348.79   \n",
       "11       193.80   -0.37  2592.14 2018-07-18                 2.70  6,201.70   \n",
       "12       194.20   -1.29  2601.77 2018-07-17                 2.68  6,214.45   \n",
       "13       196.78   -0.26  2635.78 2018-07-16                 2.65  6,296.81   \n",
       "14        79.33    0.45  2642.66 2018-07-13                 2.65  2,617.82   \n",
       "15        78.97    1.84  2630.89 2018-07-12                 2.67  2,606.16   \n",
       "16       187.49   -1.32  2583.35 2018-07-11                 2.69  6,187.29   \n",
       "17       190.51    1.22  2618.04 2018-07-10                 2.64  6,286.77   \n",
       "18       187.71    2.39  2586.60 2018-07-09                 2.47  6,194.27   \n",
       "19       182.63    0.65  2526.22 2018-07-06                 2.53  6,026.92   \n",
       "\n",
       "   index_code index_name    pb     pe turn_rate volume  vwap  \n",
       "0      801040         钢铁  1.41  10.06    1.0944  15.78  6.87  \n",
       "1      801040         钢铁  1.41  10.07    1.0272  14.81  6.87  \n",
       "2      801040         钢铁  1.45  10.38    0.7139  10.29  7.11  \n",
       "3      801040         钢铁  1.46  10.44    1.2674  18.27  7.15  \n",
       "4      801040         钢铁  1.45  10.38    1.2257  17.67  7.10  \n",
       "5      801040         钢铁  1.43  10.20    0.9418  13.58  7.01  \n",
       "6      801040         钢铁  1.44  10.30    1.4081  20.30  7.10  \n",
       "7      801040         钢铁  1.42  10.11    1.5543  22.41  6.97  \n",
       "8      801040         钢铁  1.38   9.84    1.0089  14.55  6.79  \n",
       "9      801040         钢铁  1.34   9.61    0.7451  10.74  6.63  \n",
       "10     801040         钢铁  1.33   9.49    0.7508  10.82  6.53  \n",
       "11     801040         钢铁  1.30   9.32    0.4308   6.21  6.44  \n",
       "12     801040         钢铁  1.31   9.36    0.4725   6.81  6.47  \n",
       "13     801040         钢铁  1.32   9.47    0.4635   6.67  6.56  \n",
       "14     801040         钢铁  1.34   9.53    1.5000  10.14  6.56  \n",
       "15     801040         钢铁  1.33   9.49    1.6000  10.82  6.50  \n",
       "16     801040         钢铁  1.30   9.32    0.6196   8.94  6.37  \n",
       "17     801040         钢铁  1.32   9.44    0.7228  10.42  6.47  \n",
       "18     801040         钢铁  1.30   9.33    0.6036   8.70  6.35  \n",
       "19     801040         钢铁  1.27   9.11    0.6567   9.47  6.21  "
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取申万指数每日的量化指标（pe、pb等）\n",
    "df, msg = swindex.get_index_dailyindicator('801040', '2018-01-01', '2018-08-02')\n",
    "df.head(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
